import 'package:flutter/services.dart';
// import 'package:jpush_flutter/jpush_flutter.dart';

class JPushMan {
  static final JPushMan instance = JPushMan._inverval();
  factory JPushMan() => instance;
  JPushMan._inverval() {
    init();
  }
  init() {}

  // final JPush jpush = JPush();
  void register() async {
    // try {
    //   jpush.addEventHandler(
    //       onReceiveNotification: (Map<String, dynamic> message) async {
    //     print("flutter onReceiveNotification: $message");
    //     responseNoti(message);
    //   }, onOpenNotification: (Map<String, dynamic> message) async {
    //     print("flutter onOpenNotification: $message");
    //     responseNoti(message);
    //   }, onReceiveMessage: (Map<String, dynamic> message) async {
    //     print("flutter onReceiveMessage: $message");
    //     responseNoti(message);
    //   }, onReceiveNotificationAuthorization:
    //           (Map<String, dynamic> message) async {
    //     print("flutter onReceiveNotificationAuthorization: $message");
    //     responseNoti(message);
    //   });
    // } on PlatformException {}

    // jpush.setup(
    //   appKey: "6d7565899dc8df3ae8c315ca", //你自己应用的 AppKey
    //   channel: "lewm-default",
    //   production: false,
    //   debug: true,
    // );

    // jpush.applyPushAuthority(
    //     const NotificationSettingsIOS(sound: true, alert: true, badge: true));
    // jpush.getRegistrationID().then((rid) {
    //   print("flutter get registration id : $rid");
    // });
    // setAlias();
  }

  void setAlias() {
    // jpush.setAlias('1');
  }

  responseNoti(Map<String, dynamic> message) {
    StringCodec title = message['title'];
    String alert = message['alert'];
    Map extras = message['extras'];
  }

  addLocalNoti(Map<String, dynamic> message) {
    // var localNotification = LocalNotification(
    //     id: 234,
    //     title: message['title'],
    //     buildId: 1,
    //     content: 'fdas',
    //     fireTime: DateTime.now(),
    //     subtitle: 'fasf',
    //     badge: 5,
    //     extra: {"fa": "0"});
    // jpush.sendLocalNotification(localNotification).then((res) {});
  }
}
